<?php
$success = true;
if (isset($_REQUEST["internaltransfer"]))
{
	$validator = array("sourceaccountid" => "isPosted",
						"targetaccountid" => "isPosted",
						"amount" => "isInteger");

	if (validateForm($validator, $_REQUEST))
	{
		if (!setNewInternalTransaction($_REQUEST["sourceaccountid"], $_REQUEST["targetaccountid"], $_SESSION["userid"], $_REQUEST["amount"], $_REQUEST["description"], $_REQUEST["bookingtime"]))
		{
			$success = false;
		}
	}
	else
	{
		$success = false;
	}
}

$accounts = getAccounts($_SESSION["userid"]);
$categoryTree = getCategoryTree("NULL", 1, false);
?>
			<div id="textcontainer">
				<h2>Tranzakció saját számlák között</h2>
				<p>
					<?php if (isset($success) && !$success) print "<div class=\"errortitle\">valami nem sikerult!</div>";?>
					<form name="internaltransaction" action="<?php print $_SERVER["SCRIPT_NAME"] . "?" . $_SERVER["QUERY_STRING"];?>" method="post">
						számláról: <select name="sourceaccountid">
<?php
	foreach ($accounts as $acc)
	{
		print "<option value=\"" . $acc["id"] . "\"" . (isset($_REQUEST["accountid"]) && !$success && ($_REQUEST["accountid"] == $acc["id"])?" selected=\"selected\"":"") . ">" . $acc["name"] . "</option>";
	}
?>
						</select><br/>
						számláról: <select name="targetaccountid">
<?php
	foreach ($accounts as $acc)
	{
		print "<option value=\"" . $acc["id"] . "\"" . (isset($_REQUEST["accountid"]) && !$success && ($_REQUEST["accountid"] == $acc["id"])?" selected=\"selected\"":"") . ">" . $acc["name"] . "</option>";
	}
?>
						</select><br/>
						összeg: <input type="text" name="amount"<?php print (isset($_REQUEST["amount"]) && !$success)?' value="' . $_REQUEST["amount"] . '"':"";?>/><br/>
						leírás: <textarea name="description"><?php print (isset($_REQUEST["description"]) && !$success)?$_REQUEST["description"]:"";?></textarea><br/>
						időpont: <input type="text" name="bookingtime"<?php print (isset($_REQUEST["bookingtime"]) && !$success)?' value="' . $_REQUEST["bookingtime"] . '"':"";?>/><i>(pl. 2005-10-12 15:00:00)</i><br/>
						<input type="submit" name="internaltransfer" value="Ment"/>
					</form>
				</p>
			</div>
			<!---->
